package com.huacheng.securityresource.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/res")
public class ResourceController {

    @GetMapping("/r1")
    @PreAuthorize("hasAuthority('p1')")
    public String r1() {
        System.out.println("资源服务器r1访问成功");
        return "资源服务器r1";
    }
    @GetMapping("/r2")
    @PreAuthorize("hasAuthority('p2')")
    public String r2 () {
        System.out.println("资源服务器r2访问成功");
        return "资源服务器r2";
    }
}
